package com.mall.content.articleCategory.service.impl;

import java.util.List;
import com.mall.common.utils.DateUtils;
import com.mall.common.utils.SecurityUtils;
import com.mall.content.articleCategory.domain.dto.ArticleCategoryDto;
import com.mall.content.articleCategory.domain.vo.ArticleCategoryVo;
import com.mall.content.articleCategory.mapper.ArticleCategoryMapper;
import com.mall.content.articleCategory.service.IArticleCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 文章分类Service业务层处理
 * 
 * @author mall
 * @date 2024-05-17
 */
@Service
public class ArticleCategoryServiceImpl implements IArticleCategoryService
{
    @Autowired
    private ArticleCategoryMapper articleCategoryMapper;

    /**
     * 查询文章分类
     * 
     * @param id 文章分类主键
     * @return 文章分类
     */
    @Override
    public ArticleCategoryVo selectArticleCategoryById(Long id)
    {
        return articleCategoryMapper.selectArticleCategoryById(id);
    }

    /**
     * 查询文章分类列表
     * 
     * @param articleCategoryDto 文章分类
     * @return 文章分类
     */
    @Override
    public List<ArticleCategoryVo> selectArticleCategoryList(ArticleCategoryDto articleCategoryDto)
    {
        return articleCategoryMapper.selectArticleCategoryList(articleCategoryDto);
    }

    /**
     * 新增文章分类
     * 
     * @param articleCategoryDto 文章分类
     * @return 结果
     */
    @Override
    public int insertArticleCategory(ArticleCategoryDto articleCategoryDto)
    {
        articleCategoryDto.setCreateTime(DateUtils.getNowDate());
        articleCategoryDto.setCreateId(SecurityUtils.getUserId());
        articleCategoryDto.setCreateBy(SecurityUtils.getNickName());
        return articleCategoryMapper.insertArticleCategory(articleCategoryDto);
    }

    /**
     * 修改文章分类
     * 
     * @param articleCategoryDto 文章分类
     * @return 结果
     */
    @Override
    public int updateArticleCategory(ArticleCategoryDto articleCategoryDto)
    {
        articleCategoryDto.setUpdateTime(DateUtils.getNowDate());
        articleCategoryDto.setUpdateBy(SecurityUtils.getNickName());
        return articleCategoryMapper.updateArticleCategory(articleCategoryDto);
    }

    /**
     * 批量删除文章分类
     * 
     * @param ids 需要删除的文章分类主键
     * @return 结果
     */
    @Override
    public int deleteArticleCategoryByIds(Long[] ids)
    {
        return articleCategoryMapper.deleteArticleCategoryByIds(ids);
    }

    /**
     * 删除文章分类信息
     * 
     * @param id 文章分类主键
     * @return 结果
     */
    @Override
    public int deleteArticleCategoryById(Long id)
    {
        return articleCategoryMapper.deleteArticleCategoryById(id);
    }
}
